package com.znsd.dining.room.config;

import com.znsd.dining.room.interceptor.TokenVerifyInterceptor;
import com.znsd.dining.room.resolver.LoginUserHandlerResolver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

/**
 * @ClassName MyWebMvcConfig
 * @Description: TODO
 * @Author timi
 * @Date 2020/1/2
 * @Time 21:56
 * @Version V1.0
 **/
@Configuration
public class MyWebMvcConfig implements WebMvcConfigurer {
    @Autowired
    private TokenVerifyInterceptor TokenVerifyInterceptor;
    @Autowired
    private LoginUserHandlerResolver LoginUserHandlerResolver;
    
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(TokenVerifyInterceptor).addPathPatterns("/app/**");
    }
    
    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
        argumentResolvers.add(LoginUserHandlerResolver);
    }
}
